﻿<%@ Page Language="C#" MasterPageFile="~/Template.master" AutoEventWireup="true"
    CodeFile="Search.aspx.cs" Inherits="Search" Title="Untitled Page" Culture="auto"
    meta:resourcekey="PageResource1" UICulture="auto" %>

<%@ Register Assembly="AjaxControlToolkit" Namespace="AjaxControlToolkit" TagPrefix="ajax" %>
<%@ Register Src="Controls/ProductList.ascx" TagName="ProductList" TagPrefix="uc1" %>
<asp:Content ID="Content1" ContentPlaceHolderID="head" runat="Server">

    <script type="text/javascript">
    function ChangeFeatured_onSucceed(result)
    {
        
    }
    function ChangeFeatured_onFailed()
    {
        alert("Failed");
    }
    function setSearchCategory(id, name)
    {
        var textBox = document.getElementById('<%= CategorySearchField.ClientID %>');
        var categoryIdField = document.getElementById('<%= CategoryIdField.ClientID %>');
        categoryIdField.value = id;
        textBox.value = name;
    }
    </script>

</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="ContentPlaceHolder1" runat="Server">
    <asp:ScriptManager runat="server">
        <Services>
            <asp:ServiceReference Path="~/WebServices/ShoppingCartService.svc" />
            <asp:ServiceReference Path="~/WebServices/ProductService.svc" />
        </Services>
        <Scripts>
            <asp:ScriptReference Path="~/Scripts/GeneralScripts.js" />
        </Scripts>
    </asp:ScriptManager>
    <div class="item">
        <h5>
            <asp:Literal runat="server" meta:resourcekey="ContentTitle" /></h5>
        <div class="body">
            <div>
                <asp:Literal runat="server" meta:resourcekey="ProductTitleSearchLabel" /></div>
            <div>
                <asp:TextBox runat="server" ID="ProductTitleSearchField" /></div>
            <div>
                <asp:Literal runat="server" meta:resourcekey="CategorySearchLabel" /></div>
            <div>
                <asp:TextBox runat="server" ID="CategorySearchField" AutoCompleteType="Disabled" Columns="60"
                    ReadOnly="true" />
                <div runat="server" id="MenuPanel" class="DropDownMenu">
                    <div id="submenu" style="width: 220px">
                        <asp:Menu runat="server" ID="CategoriesMenu" DataSourceID="XMLMenu">
                            <DataBindings>
                                <asp:MenuItemBinding DataMember="MenuItem" NavigateUrlField="NavigateUrl" TextField="Text"
                                    ToolTipField="ToolTip" />
                            </DataBindings>
                        </asp:Menu>
                        <asp:XmlDataSource EnableCaching="false" TransformFile="~/XSLT/TransformMenuXML.xslt"
                            XPath="MenuItems/MenuItem/MenuItem" runat="server" ID="XMLMenu" />
                    </div>
                </div>
                <asp:HiddenField runat="server" ID="CategoryIdField" />
                <ajax:PopupControlExtender ID="PopEx" runat="server" TargetControlID="CategorySearchField"
                    PopupControlID="MenuPanel" Position="Bottom" />
            </div>
            
            <div>
                <asp:Button runat="server" meta:resourcekey="SearchButton" ID="SearchButton" OnClick="SearchButton_Click" /></div>
        </div>
    </div>
    <uc1:ProductList ID="ProductListVertical1" runat="server">
        <DataSourceTemplate>
            <asp:ObjectDataSource ID="ProductListDS" runat="server" SelectMethod="SearchProducts"
                TypeName="DAL.Product">
                <SelectParameters>
                    <asp:QueryStringParameter Name="title" QueryStringField="q" Type="String" />
                    <asp:QueryStringParameter Name="categoryId" QueryStringField="catId" Type="Int32" />
                </SelectParameters>
            </asp:ObjectDataSource>
        </DataSourceTemplate>
    </uc1:ProductList>
</asp:Content>
